# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=pytz
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2023.3
pkgrel=2
pkgdesc="Cross platform time zone library for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://pypi.org/project/pytz/"
license=("MIT")
depends=("${MINGW_PACKAGE_PREFIX}-python")
source=(https://pypi.io/packages/source/p/pytz/pytz-${pkgver}.tar.gz)
sha256sums=('1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588')
validpgpkeys=('C7ECC365AB6F255E1EB9BA1701FA998FBAC6374A')

prepare() {
  rm -rf python-build-${CARCH} | true
  cp -r "pytz-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
      ${MINGW_PREFIX}/bin/python setup.py build
}

check(){
  msg "Python test for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}/pytz/tests"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
     ${MINGW_PREFIX}/bin/python test_tzinfo.py
}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  install -D LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
